//
//  TempDataView.m
//  UEAssistant
//
//  Created by mac on 2017/3/22.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "TempDataView.h"

@interface TempDataView ()

{

    NSString            *_title;
}

@end

@implementation TempDataView

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{

    if (self = [super initWithFrame:frame]) {
        _title = title;
        [self setLabelWithFrame:frame];
    }
    return self;
}

+ (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{

    TempDataView *view = [[TempDataView alloc]initWithFrame:frame title:title];
    return view;
}

- (void)setLabelWithFrame:(CGRect)frame{

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height-10)];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor darkGrayColor];
    label.text = _title;
    label.font = [UIFont systemFontOfSize:FLEXIBLE(16)];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [UIView animateWithDuration:0.6 animations:^{
            self.alpha = 0;
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
    });

    
}

- (void)drawRect:(CGRect)rect{

    UIBezierPath* path = [UIBezierPath bezierPath];
    path.lineWidth = 1.0;

    UIColor *color = [UIColor colorWithWhite:1 alpha:1];
    [color set]; //设置线条颜色
    
    path.lineCapStyle = kCGLineCapRound; //线条拐角
    path.lineJoinStyle = kCGLineJoinRound; //终点处理
    
    [path moveToPoint:CGPointMake(0, 0)];//起点
    [path addLineToPoint:CGPointMake(200, 0)];
    [path addLineToPoint:CGPointMake(200, 30)];
    [path addLineToPoint:CGPointMake(50, 30)];
    [path addLineToPoint:CGPointMake(40, 40)];
    [path addLineToPoint:CGPointMake(30, 30)];
    [path addLineToPoint:CGPointMake(0, 30)];
    [path closePath];//第五条线通过调用closePath方法得到的
    
    [path stroke];//Draws line 根据坐标点连线
    [path fill];//颜色填充

}

@end
